/**
 * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
 *
 * @author David Sehnal <david.sehnal@gmail.com>
 * @author Alexander Rose <alexander.rose@weirdbyte.de>
 */

export const TransformData = [
    [1.0, 0.0, 0.0, 0.0],
    [0.0, 1.0, 0.0, 0.0],
    [0.0, 0.0, 1.0, 0.0],
    [-1.0, 0.0, 0.0, 0.0],
    [0.0, -1.0, 0.0, 0.0],
    [0.0, 0.0, -1.0, 0.0],
    [0.0, 1.0, 0.0, 0.5],
    [1.0, 0.0, 0.0, 0.5],
    [-1.0, 0.0, 0.0, 0.5],
    [0.0, 0.0, 1.0, 0.5],
    [0.0, -1.0, 0.0, 0.5],
    [0.0, 0.0, -1.0, 0.5],
    [1.0, 0.0, 0.0, 0.25],
    [0.0, -1.0, 0.0, 0.25],
    [0.0, 0.0, 1.0, 0.25],
    [-1.0, 0.0, 0.0, 0.25],
    [0.0, 1.0, 0.0, 0.25],
    [0.0, -1.0, 0.0, 0.75],
    [0.0, 0.0, 1.0, 0.75],
    [0.0, 1.0, 0.0, 0.75],
    [1.0, 0.0, 0.0, 0.75],
    [-1.0, 0.0, 0.0, 0.75],
    [0.0, 0.0, -1.0, 0.25],
    [0.0, 0.0, -1.0, 0.75],
    [1.0, -1.0, 0.0, 0.0],
    [-1.0, 1.0, 0.0, 0.0],
    [0.0, 0.0, 1.0, 1 / 3],
    [0.0, 0.0, 1.0, 2 / 3],
    [1.0, 0.0, 0.0, 2 / 3],
    [0.0, 1.0, 0.0, 1 / 3],
    [0.0, -1.0, 0.0, 2 / 3],
    [1.0, -1.0, 0.0, 1 / 3],
    [-1.0, 1.0, 0.0, 2 / 3],
    [-1.0, 0.0, 0.0, 1 / 3],
    [1.0, 0.0, 0.0, 1 / 3],
    [0.0, 1.0, 0.0, 2 / 3],
    [0.0, -1.0, 0.0, 1 / 3],
    [1.0, -1.0, 0.0, 2 / 3],
    [-1.0, 1.0, 0.0, 1 / 3],
    [-1.0, 0.0, 0.0, 2 / 3],
    [0.0, 0.0, -1.0, 1 / 3],
    [0.0, 0.0, -1.0, 2 / 3],
    [0.0, 0.0, 1.0, 5 / 6],
    [0.0, 0.0, 1.0, 1 / 6],
    [0.0, 0.0, -1.0, 5 / 6],
    [0.0, 0.0, -1.0, 1 / 6],
];

export const OperatorData = [
    [0, 1, 2],
    [3, 4, 5],
    [3, 1, 5],
    [3, 6, 5],
    [7, 6, 2],
    [8, 6, 5],
    [0, 4, 2],
    [0, 4, 9],
    [7, 10, 2],
    [7, 10, 9],
    [0, 10, 2],
    [8, 10, 5],
    [3, 1, 11],
    [3, 6, 11],
    [0, 10, 9],
    [8, 6, 11],
    [3, 4, 2],
    [0, 4, 5],
    [3, 4, 9],
    [7, 10, 5],
    [8, 4, 9],
    [8, 10, 9],
    [8, 10, 2],
    [0, 6, 9],
    [3, 10, 9],
    [0, 10, 11],
    [7, 1, 9],
    [8, 1, 11],
    [7, 4, 11],
    [7, 6, 9],
    [7, 10, 11],
    [3, 10, 2],
    [8, 1, 5],
    [0, 4, 11],
    [3, 1, 2],
    [3, 1, 9],
    [7, 4, 2],
    [8, 1, 2],
    [8, 1, 9],
    [3, 6, 9],
    [7, 4, 9],
    [8, 6, 2],
    [8, 6, 9],
    [3, 6, 2],
    [12, 13, 14],
    [15, 16, 14],
    [12, 17, 18],
    [15, 19, 18],
    [20, 13, 18],
    [21, 16, 18],
    [20, 17, 14],
    [21, 19, 14],
    [0, 1, 5],
    [8, 10, 11],
    [7, 6, 11],
    [7, 6, 5],
    [8, 4, 2],
    [7, 4, 5],
    [7, 1, 5],
    [7, 1, 11],
    [0, 10, 5],
    [0, 1, 11],
    [0, 6, 11],
    [0, 6, 5],
    [3, 10, 11],
    [8, 4, 11],
    [15, 13, 22],
    [12, 16, 22],
    [15, 17, 23],
    [12, 19, 23],
    [21, 13, 23],
    [20, 16, 23],
    [21, 17, 22],
    [20, 19, 22],
    [4, 0, 2],
    [1, 3, 2],
    [4, 0, 14],
    [1, 3, 18],
    [4, 0, 9],
    [1, 3, 9],
    [4, 0, 18],
    [1, 3, 14],
    [10, 7, 9],
    [6, 8, 9],
    [4, 7, 14],
    [6, 3, 18],
    [10, 0, 18],
    [1, 8, 14],
    [1, 3, 5],
    [4, 0, 5],
    [6, 8, 11],
    [10, 7, 11],
    [1, 3, 11],
    [4, 0, 11],
    [10, 7, 2],
    [6, 8, 2],
    [3, 10, 22],
    [7, 1, 23],
    [8, 4, 23],
    [0, 6, 22],
    [1, 0, 5],
    [4, 3, 5],
    [1, 0, 23],
    [4, 3, 22],
    [10, 7, 14],
    [6, 8, 18],
    [8, 6, 22],
    [7, 10, 23],
    [4, 3, 11],
    [1, 0, 11],
    [1, 0, 22],
    [4, 3, 23],
    [10, 7, 18],
    [6, 8, 14],
    [8, 6, 23],
    [7, 10, 22],
    [6, 7, 11],
    [10, 8, 11],
    [8, 1, 23],
    [0, 10, 22],
    [3, 6, 22],
    [7, 4, 23],
    [4, 3, 2],
    [1, 0, 2],
    [10, 8, 2],
    [6, 7, 2],
    [4, 3, 9],
    [1, 0, 9],
    [10, 8, 9],
    [6, 7, 9],
    [4, 8, 14],
    [6, 0, 18],
    [10, 3, 18],
    [1, 7, 14],
    [4, 8, 18],
    [6, 0, 14],
    [10, 3, 14],
    [1, 7, 18],
    [6, 7, 5],
    [10, 8, 5],
    [6, 8, 5],
    [10, 7, 5],
    [8, 1, 22],
    [0, 10, 23],
    [3, 6, 23],
    [7, 4, 22],
    [4, 24, 2],
    [25, 3, 2],
    [4, 24, 26],
    [25, 3, 27],
    [4, 24, 27],
    [25, 3, 26],
    [28, 29, 26],
    [30, 31, 26],
    [32, 33, 26],
    [34, 35, 27],
    [36, 37, 27],
    [38, 39, 27],
    [2, 0, 1],
    [1, 2, 0],
    [1, 25, 5],
    [24, 0, 5],
    [39, 36, 40],
    [35, 38, 40],
    [37, 34, 40],
    [33, 30, 41],
    [29, 32, 41],
    [31, 28, 41],
    [5, 3, 4],
    [4, 5, 3],
    [25, 1, 5],
    [0, 24, 5],
    [24, 4, 5],
    [3, 25, 5],
    [4, 3, 41],
    [25, 1, 40],
    [24, 4, 41],
    [3, 25, 40],
    [4, 3, 40],
    [25, 1, 41],
    [24, 4, 40],
    [3, 25, 41],
    [35, 34, 40],
    [37, 36, 40],
    [39, 38, 40],
    [29, 28, 41],
    [31, 30, 41],
    [33, 32, 41],
    [3, 5, 4],
    [5, 4, 3],
    [25, 1, 2],
    [0, 24, 2],
    [24, 4, 2],
    [3, 25, 2],
    [25, 1, 9],
    [0, 24, 9],
    [24, 4, 9],
    [3, 25, 9],
    [30, 33, 26],
    [32, 29, 26],
    [28, 31, 26],
    [36, 39, 27],
    [38, 35, 27],
    [34, 37, 27],
    [0, 2, 1],
    [2, 1, 0],
    [30, 33, 42],
    [32, 29, 42],
    [28, 31, 42],
    [36, 39, 43],
    [38, 35, 43],
    [34, 37, 43],
    [7, 9, 6],
    [9, 6, 7],
    [25, 1, 11],
    [0, 24, 11],
    [24, 4, 11],
    [3, 25, 11],
    [35, 34, 44],
    [37, 36, 44],
    [39, 38, 44],
    [29, 28, 45],
    [31, 30, 45],
    [33, 32, 45],
    [8, 11, 10],
    [11, 10, 8],
    [1, 25, 2],
    [24, 0, 2],
    [1, 25, 42],
    [24, 0, 43],
    [1, 25, 43],
    [24, 0, 42],
    [1, 25, 27],
    [24, 0, 26],
    [1, 25, 26],
    [24, 0, 27],
    [1, 25, 9],
    [24, 0, 9],
    [4, 24, 5],
    [25, 3, 5],
    [4, 24, 11],
    [25, 3, 11],
    [1, 0, 40],
    [4, 3, 44],
    [0, 24, 45],
    [1, 0, 41],
    [4, 3, 45],
    [0, 24, 44],
    [0, 24, 40],
    [0, 24, 41],
    [2, 3, 4],
    [5, 3, 1],
    [5, 0, 4],
    [4, 2, 3],
    [1, 5, 3],
    [4, 5, 0],
    [2, 7, 6],
    [2, 8, 10],
    [5, 8, 6],
    [5, 7, 10],
    [1, 9, 7],
    [4, 9, 8],
    [1, 11, 8],
    [4, 11, 7],
    [9, 0, 6],
    [9, 3, 10],
    [11, 3, 6],
    [11, 0, 10],
    [6, 2, 7],
    [10, 2, 8],
    [6, 5, 8],
    [10, 5, 7],
    [9, 7, 1],
    [9, 8, 4],
    [11, 8, 1],
    [11, 7, 4],
    [6, 9, 0],
    [10, 9, 3],
    [6, 11, 3],
    [10, 11, 0],
    [9, 7, 6],
    [9, 8, 10],
    [11, 8, 6],
    [11, 7, 10],
    [6, 9, 7],
    [10, 9, 8],
    [6, 11, 8],
    [10, 11, 7],
    [2, 3, 10],
    [5, 8, 1],
    [11, 0, 4],
    [10, 2, 3],
    [1, 5, 8],
    [4, 11, 0],
    [5, 0, 1],
    [2, 0, 4],
    [2, 3, 1],
    [1, 5, 0],
    [4, 2, 0],
    [1, 2, 3],
    [11, 8, 10],
    [11, 7, 6],
    [9, 7, 10],
    [9, 8, 6],
    [10, 11, 8],
    [6, 11, 7],
    [10, 9, 7],
    [6, 9, 8],
    [5, 8, 10],
    [5, 7, 6],
    [2, 7, 10],
    [2, 8, 6],
    [4, 11, 8],
    [1, 11, 7],
    [4, 9, 7],
    [1, 9, 8],
    [11, 3, 10],
    [11, 0, 6],
    [9, 0, 10],
    [9, 3, 6],
    [10, 5, 8],
    [6, 5, 7],
    [10, 2, 7],
    [6, 2, 8],
    [11, 8, 4],
    [11, 7, 1],
    [9, 7, 4],
    [9, 8, 1],
    [10, 11, 3],
    [6, 11, 0],
    [10, 9, 0],
    [6, 9, 3],
    [22, 15, 13],
    [22, 12, 16],
    [14, 12, 13],
    [14, 15, 16],
    [13, 22, 15],
    [16, 22, 12],
    [13, 14, 12],
    [16, 14, 15],
    [22, 21, 17],
    [22, 20, 19],
    [14, 20, 17],
    [14, 21, 19],
    [13, 23, 21],
    [16, 23, 20],
    [13, 18, 20],
    [16, 18, 21],
    [23, 15, 17],
    [23, 12, 19],
    [18, 12, 17],
    [18, 15, 19],
    [17, 22, 21],
    [19, 22, 20],
    [17, 14, 20],
    [19, 14, 21],
    [23, 21, 13],
    [23, 20, 16],
    [18, 20, 13],
    [18, 21, 16],
    [17, 23, 15],
    [19, 23, 12],
    [17, 18, 12],
    [19, 18, 15],
    [5, 0, 6],
    [2, 7, 4],
    [9, 3, 1],
    [6, 5, 0],
    [4, 2, 7],
    [1, 9, 3],
    [0, 2, 4],
    [3, 2, 1],
    [0, 5, 1],
    [2, 1, 3],
    [2, 4, 0],
    [5, 1, 0],
    [7, 9, 10],
    [8, 9, 6],
    [7, 11, 6],
    [9, 6, 8],
    [9, 10, 7],
    [11, 6, 7],
    [1, 7, 11],
    [4, 8, 11],
    [1, 8, 9],
    [4, 7, 9],
    [0, 9, 10],
    [3, 9, 6],
    [3, 11, 10],
    [0, 11, 6],
    [2, 6, 8],
    [2, 10, 7],
    [5, 6, 7],
    [5, 10, 8],
    [6, 0, 11],
    [10, 3, 11],
    [6, 3, 9],
    [10, 0, 9],
    [7, 2, 10],
    [8, 2, 6],
    [8, 5, 10],
    [7, 5, 6],
    [9, 1, 8],
    [9, 4, 7],
    [11, 1, 7],
    [11, 4, 8],
    [7, 9, 4],
    [8, 9, 1],
    [8, 11, 4],
    [7, 11, 1],
    [9, 6, 3],
    [9, 10, 0],
    [11, 6, 0],
    [11, 10, 3],
    [19, 12, 23],
    [13, 15, 22],
    [16, 21, 18],
    [17, 20, 14],
    [20, 14, 17],
    [21, 18, 16],
    [15, 22, 13],
    [12, 23, 19],
    [18, 16, 21],
    [14, 17, 20],
    [23, 19, 12],
    [22, 13, 15],
    [19, 20, 22],
    [13, 21, 23],
    [16, 15, 14],
    [17, 12, 18],
    [20, 18, 13],
    [21, 14, 19],
    [15, 23, 17],
    [12, 22, 16],
    [18, 19, 15],
    [14, 13, 12],
    [23, 16, 20],
    [22, 17, 21],
    [16, 12, 22],
    [17, 15, 23],
    [19, 21, 14],
    [13, 20, 18],
    [12, 14, 13],
    [15, 18, 19],
    [21, 22, 17],
    [20, 23, 16],
    [14, 16, 15],
    [18, 17, 12],
    [22, 19, 20],
    [23, 13, 21],
    [16, 20, 23],
    [17, 21, 22],
    [19, 15, 18],
    [13, 12, 14],
    [12, 18, 17],
    [15, 14, 16],
    [21, 23, 13],
    [20, 22, 19],
    [14, 19, 21],
    [18, 13, 20],
    [22, 16, 12],
    [23, 17, 15],
    [19, 12, 22],
    [17, 21, 23],
    [16, 15, 18],
    [13, 20, 14],
    [20, 14, 13],
    [15, 18, 16],
    [21, 23, 17],
    [12, 22, 19],
    [18, 16, 15],
    [14, 13, 20],
    [22, 19, 12],
    [23, 17, 21],
    [3, 2, 4],
    [3, 5, 1],
    [0, 5, 4],
    [2, 4, 3],
    [5, 1, 3],
    [5, 4, 0],
    [1, 7, 9],
    [4, 8, 9],
    [1, 8, 11],
    [4, 7, 11],
    [0, 9, 6],
    [3, 9, 10],
    [3, 11, 6],
    [0, 11, 10],
    [2, 6, 7],
    [2, 10, 8],
    [5, 6, 8],
    [5, 10, 7],
    [6, 0, 9],
    [10, 3, 9],
    [6, 3, 11],
    [10, 0, 11],
    [7, 2, 6],
    [8, 2, 10],
    [8, 5, 6],
    [7, 5, 10],
    [9, 1, 7],
    [9, 4, 8],
    [11, 1, 8],
    [11, 4, 7],
    [7, 9, 1],
    [8, 9, 4],
    [8, 11, 1],
    [7, 11, 4],
    [9, 6, 0],
    [9, 10, 3],
    [11, 6, 3],
    [11, 10, 0],
    [8, 9, 10],
    [8, 11, 6],
    [7, 11, 10],
    [9, 10, 8],
    [11, 6, 8],
    [11, 10, 7],
    [6, 0, 2],
    [10, 3, 2],
    [6, 3, 5],
    [10, 0, 5],
    [7, 2, 1],
    [8, 2, 4],
    [8, 5, 1],
    [7, 5, 4],
    [9, 1, 0],
    [9, 4, 3],
    [11, 1, 3],
    [11, 4, 0],
    [1, 7, 2],
    [4, 8, 2],
    [1, 8, 5],
    [4, 7, 5],
    [0, 9, 1],
    [3, 9, 4],
    [3, 11, 1],
    [0, 11, 4],
    [2, 6, 0],
    [2, 10, 3],
    [5, 6, 3],
    [5, 10, 0],
    [0, 2, 6],
    [3, 2, 10],
    [3, 5, 6],
    [0, 5, 10],
    [2, 1, 7],
    [2, 4, 8],
    [5, 1, 8],
    [5, 4, 7],
    [16, 12, 14],
    [13, 21, 18],
    [19, 15, 23],
    [17, 20, 22],
    [12, 14, 16],
    [21, 18, 13],
    [15, 23, 19],
    [20, 22, 17],
    [14, 16, 12],
    [18, 13, 21],
    [23, 19, 15],
    [22, 17, 20],
    [19, 20, 18],
    [17, 15, 14],
    [16, 21, 22],
    [13, 12, 23],
    [20, 18, 19],
    [15, 14, 17],
    [21, 22, 16],
    [12, 23, 13],
    [18, 19, 20],
    [14, 17, 15],
    [22, 16, 21],
    [23, 13, 12],
    [6, 0, 5],
    [10, 3, 5],
    [6, 3, 2],
    [10, 0, 2],
    [7, 2, 4],
    [8, 2, 1],
    [8, 5, 4],
    [7, 5, 1],
    [9, 1, 3],
    [9, 4, 0],
    [11, 1, 0],
    [11, 4, 3],
    [1, 7, 5],
    [4, 8, 5],
    [1, 8, 2],
    [4, 7, 2],
    [0, 9, 4],
    [3, 9, 1],
    [3, 11, 4],
    [0, 11, 1],
    [2, 6, 3],
    [2, 10, 0],
    [5, 6, 0],
    [5, 10, 3],
    [0, 2, 10],
    [3, 2, 6],
    [3, 5, 10],
    [0, 5, 6],
    [2, 1, 8],
    [2, 4, 7],
    [5, 1, 7],
    [5, 4, 8],
    [21, 17, 23],
    [20, 16, 22],
    [12, 13, 18],
    [15, 19, 14],
    [23, 21, 17],
    [22, 20, 16],
    [18, 12, 13],
    [14, 15, 19],
    [17, 23, 21],
    [16, 22, 20],
    [13, 18, 12],
    [19, 14, 15],
    [21, 13, 22],
    [20, 19, 23],
    [12, 17, 14],
    [15, 16, 18],
    [23, 15, 13],
    [22, 12, 19],
    [18, 20, 17],
    [14, 21, 16],
    [17, 22, 15],
    [16, 23, 12],
    [13, 14, 20],
    [19, 18, 21],
    [15, 17, 22],
    [12, 16, 23],
    [20, 13, 14],
    [21, 19, 18],
    [22, 21, 13],
    [23, 20, 19],
    [14, 12, 17],
    [18, 15, 16],
    [13, 23, 15],
    [19, 22, 12],
    [17, 18, 20],
    [16, 14, 21],
    [15, 13, 23],
    [12, 19, 22],
    [20, 17, 18],
    [21, 16, 14],
    [22, 15, 17],
    [23, 12, 16],
    [14, 20, 13],
    [18, 21, 19],
    [13, 22, 21],
    [19, 23, 20],
    [17, 14, 12],
    [16, 18, 15],
    [6, 5, 3],
    [4, 9, 3],
    [9, 3, 4],
    [5, 7, 4],
    [4, 5, 7],
    [5, 3, 6],
];

export const GroupData = [
    [0],
    [0, 1],
    [0, 2],
    [0, 3],
    [0, 2, 4, 5],
    [0, 6],
    [0, 7],
    [0, 6, 4, 8],
    [0, 7, 4, 9],
    [0, 6, 2, 1],
    [0, 3, 1, 10],
    [0, 6, 2, 1, 4, 8, 5, 11],
    [0, 12, 1, 7],
    [0, 1, 13, 14],
    [0, 12, 1, 7, 4, 15, 11, 9],
    [0, 16, 2, 17],
    [0, 18, 12, 17],
    [0, 16, 5, 19],
    [0, 20, 13, 19],
    [0, 18, 12, 17, 4, 21, 15, 19],
    [0, 16, 2, 17, 4, 22, 5, 19],
    [0, 16, 2, 17, 23, 24, 13, 25, 26, 20, 27, 28, 4, 22, 5, 19],
    [0, 16, 17, 2, 29, 21, 30, 15],
    [0, 20, 13, 19, 29, 31, 32, 33],
    [0, 16, 6, 34],
    [0, 18, 7, 34],
    [0, 16, 7, 35],
    [0, 16, 36, 37],
    [0, 18, 36, 38],
    [0, 16, 14, 39],
    [0, 20, 40, 34],
    [0, 16, 8, 41],
    [0, 18, 8, 42],
    [0, 16, 9, 42],
    [0, 16, 6, 34, 4, 22, 8, 41],
    [0, 18, 7, 34, 4, 21, 9, 41],
    [0, 16, 7, 35, 4, 22, 9, 42],
    [0, 16, 6, 34, 23, 24, 14, 39],
    [0, 16, 10, 43, 23, 24, 7, 35],
    [0, 16, 36, 37, 23, 24, 9, 42],
    [0, 16, 8, 41, 23, 24, 40, 38],
    [0, 16, 6, 34, 23, 24, 14, 39, 26, 20, 40, 38, 4, 22, 8, 41],
    [0, 16, 44, 45, 23, 24, 46, 47, 26, 20, 48, 49, 4, 22, 50, 51],
    [0, 16, 6, 34, 29, 21, 9, 42],
    [0, 16, 8, 41, 29, 21, 7, 35],
    [0, 16, 36, 37, 29, 21, 14, 39],
    [0, 16, 2, 17, 1, 52, 6, 34],
    [0, 16, 2, 17, 53, 54, 9, 42],
    [0, 16, 12, 33, 1, 52, 7, 35],
    [0, 16, 2, 17, 11, 55, 8, 41],
    [0, 56, 2, 57, 1, 58, 6, 37],
    [0, 56, 15, 25, 1, 58, 9, 39],
    [0, 20, 27, 17, 1, 59, 40, 34],
    [0, 56, 12, 28, 1, 58, 7, 38],
    [0, 16, 5, 19, 1, 52, 8, 41],
    [0, 22, 13, 28, 1, 55, 14, 38],
    [0, 18, 13, 60, 1, 61, 14, 43],
    [0, 16, 15, 30, 1, 52, 9, 42],
    [0, 16, 5, 19, 11, 55, 6, 34],
    [0, 21, 12, 19, 1, 54, 7, 41],
    [0, 20, 13, 19, 1, 59, 14, 41],
    [0, 20, 3, 30, 1, 59, 10, 42],
    [0, 18, 12, 17, 1, 61, 7, 34, 4, 21, 15, 19, 11, 54, 9, 41],
    [0, 24, 13, 17, 1, 62, 14, 34, 4, 20, 27, 19, 11, 59, 40, 41],
    [0, 16, 2, 17, 1, 52, 6, 34, 4, 22, 5, 19, 11, 55, 8, 41],
    [0, 16, 12, 33, 1, 52, 7, 35, 4, 22, 15, 30, 11, 55, 9, 42],
    [0, 31, 3, 17, 1, 63, 10, 34, 4, 56, 32, 19, 11, 58, 36, 41],
    [0, 22, 2, 19, 64, 59, 14, 38, 4, 16, 5, 17, 65, 62, 40, 39],
    [0, 16, 2, 17, 1, 52, 6, 34, 23, 24, 13, 25, 64, 62, 14, 39, 26, 20, 27, 28, 65, 59, 40, 38, 4, 22, 5, 19, 11, 55, 8, 41],
    [0, 16, 2, 17, 66, 67, 44, 45, 23, 24, 13, 25, 68, 69, 46, 47, 26, 20, 27, 28, 70, 71, 48, 49, 4, 22, 5, 19, 72, 73, 50, 51],
    [0, 16, 2, 17, 1, 52, 6, 34, 29, 21, 15, 30, 53, 54, 9, 42],
    [0, 16, 5, 19, 1, 52, 8, 41, 29, 21, 12, 33, 53, 54, 7, 35],
    [0, 20, 13, 19, 1, 59, 14, 41, 29, 31, 32, 33, 53, 63, 36, 35],
    [0, 31, 3, 17, 1, 63, 10, 34, 29, 20, 27, 30, 53, 59, 40, 42],
    [0, 16, 74, 75],
    [0, 18, 76, 77],
    [0, 16, 78, 79],
    [0, 18, 80, 81],
    [0, 16, 74, 75, 29, 21, 82, 83],
    [0, 21, 84, 85, 29, 16, 86, 87],
    [0, 16, 88, 89],
    [0, 16, 88, 89, 29, 21, 90, 91],
    [0, 16, 74, 75, 1, 52, 88, 89],
    [0, 16, 78, 79, 1, 52, 92, 93],
    [0, 16, 94, 95, 11, 55, 88, 89],
    [0, 16, 82, 83, 53, 54, 88, 89],
    [0, 16, 74, 75, 1, 52, 88, 89, 29, 21, 82, 83, 53, 54, 90, 91],
    [0, 21, 84, 85, 96, 97, 88, 91, 29, 16, 86, 87, 98, 99, 90, 89],
    [0, 16, 74, 75, 2, 17, 100, 101],
    [0, 16, 94, 95, 5, 19, 100, 101],
    [0, 18, 76, 77, 2, 33, 102, 103],
    [0, 18, 104, 105, 106, 107, 100, 108],
    [0, 16, 78, 79, 2, 17, 109, 108],
    [0, 16, 82, 83, 15, 30, 100, 101],
    [0, 18, 80, 81, 2, 33, 110, 111],
    [0, 18, 112, 113, 114, 115, 100, 108],
    [0, 16, 74, 75, 2, 17, 100, 101, 29, 21, 82, 83, 15, 30, 116, 117],
    [0, 21, 84, 85, 118, 119, 116, 101, 29, 16, 86, 87, 120, 121, 100, 117],
    [0, 16, 74, 75, 6, 34, 122, 123],
    [0, 16, 74, 75, 8, 41, 124, 125],
    [0, 16, 78, 79, 7, 35, 122, 123],
    [0, 16, 82, 83, 9, 42, 122, 123],
    [0, 16, 74, 75, 7, 35, 126, 127],
    [0, 16, 74, 75, 9, 42, 128, 129],
    [0, 16, 78, 79, 6, 34, 126, 127],
    [0, 16, 78, 79, 8, 41, 128, 129],
    [0, 16, 74, 75, 6, 34, 122, 123, 29, 21, 82, 83, 9, 42, 128, 129],
    [0, 16, 74, 75, 7, 35, 126, 127, 29, 21, 82, 83, 8, 41, 124, 125],
    [0, 21, 84, 85, 6, 42, 130, 131, 29, 16, 86, 87, 9, 34, 132, 133],
    [0, 21, 84, 85, 7, 41, 134, 135, 29, 16, 86, 87, 8, 35, 136, 137],
    [0, 16, 89, 88, 2, 17, 122, 123],
    [0, 16, 89, 88, 12, 33, 126, 127],
    [0, 16, 89, 88, 5, 19, 124, 125],
    [0, 16, 89, 88, 15, 30, 128, 129],
    [0, 16, 88, 89, 6, 34, 100, 101],
    [0, 16, 89, 88, 7, 35, 109, 108],
    [0, 16, 89, 88, 8, 41, 138, 139],
    [0, 16, 89, 88, 9, 42, 116, 117],
    [0, 16, 89, 88, 6, 34, 100, 101, 29, 21, 91, 90, 9, 42, 116, 117],
    [0, 16, 89, 88, 7, 35, 109, 108, 29, 21, 91, 90, 8, 41, 138, 139],
    [0, 16, 89, 88, 2, 17, 122, 123, 29, 21, 91, 90, 15, 30, 128, 129],
    [0, 16, 89, 88, 118, 121, 132, 131, 29, 21, 91, 90, 120, 119, 130, 133],
    [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123],
    [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127],
    [0, 16, 74, 75, 2, 17, 100, 101, 11, 55, 140, 141, 8, 41, 124, 125],
    [0, 16, 74, 75, 2, 17, 100, 101, 53, 54, 90, 91, 9, 42, 128, 129],
    [0, 16, 74, 75, 5, 19, 138, 139, 1, 52, 88, 89, 8, 41, 124, 125],
    [0, 16, 74, 75, 15, 30, 116, 117, 1, 52, 88, 89, 9, 42, 128, 129],
    [0, 16, 94, 95, 5, 19, 100, 101, 11, 55, 88, 89, 6, 34, 124, 125],
    [0, 16, 94, 95, 15, 30, 109, 108, 11, 55, 88, 89, 7, 35, 128, 129],
    [0, 16, 78, 79, 2, 17, 109, 108, 1, 52, 92, 93, 6, 34, 126, 127],
    [0, 16, 78, 79, 12, 33, 100, 101, 1, 52, 92, 93, 7, 35, 122, 123],
    [0, 16, 82, 83, 12, 33, 138, 139, 53, 54, 88, 89, 8, 41, 126, 127],
    [0, 16, 82, 83, 2, 17, 116, 117, 53, 54, 88, 89, 9, 42, 122, 123],
    [0, 16, 78, 79, 5, 19, 116, 117, 1, 52, 92, 93, 8, 41, 128, 129],
    [0, 16, 82, 83, 15, 30, 100, 101, 1, 52, 90, 91, 9, 42, 122, 123],
    [0, 16, 82, 83, 15, 30, 100, 101, 53, 54, 88, 89, 6, 34, 128, 129],
    [0, 16, 82, 83, 5, 19, 109, 108, 53, 54, 88, 89, 7, 35, 124, 125],
    [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123, 29, 21, 82, 83, 15, 30, 116, 117, 53, 54, 90, 91, 9, 42, 128, 129],
    [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127, 29, 21, 82, 83, 5, 19, 138, 139, 53, 54, 90, 91, 8, 41, 124, 125],
    [0, 21, 84, 85, 118, 119, 116, 101, 96, 97, 88, 91, 9, 34, 132, 133, 29, 16, 86, 87, 120, 121, 100, 117, 98, 99, 90, 89, 6, 42, 130, 131],
    [0, 21, 84, 85, 142, 143, 138, 108, 96, 97, 88, 91, 8, 35, 136, 137, 29, 16, 86, 87, 144, 145, 109, 139, 98, 99, 90, 89, 7, 41, 134, 135],
    [0, 146, 147],
    [0, 148, 149],
    [0, 150, 151],
    [0, 146, 147, 152, 153, 154, 155, 156, 157],
    [0, 158, 159],
    [0, 146, 147, 1, 160, 161],
    [0, 146, 147, 1, 160, 161, 152, 153, 154, 162, 163, 164, 155, 156, 157, 165, 166, 167],
    [0, 158, 159, 1, 168, 169],
    [0, 146, 147, 101, 170, 171],
    [0, 146, 147, 100, 172, 173],
    [0, 148, 149, 174, 175, 171],
    [0, 148, 149, 100, 176, 177],
    [0, 150, 151, 178, 179, 171],
    [0, 150, 151, 100, 180, 181],
    [0, 146, 147, 100, 172, 173, 152, 153, 154, 182, 183, 184, 155, 156, 157, 185, 186, 187],
    [0, 158, 159, 101, 188, 189],
    [0, 146, 147, 122, 190, 191],
    [0, 146, 147, 123, 192, 193],
    [0, 146, 147, 126, 194, 195],
    [0, 146, 147, 127, 196, 197],
    [0, 146, 147, 122, 190, 191, 152, 153, 154, 198, 199, 200, 155, 156, 157, 201, 202, 203],
    [0, 158, 159, 123, 204, 205],
    [0, 146, 147, 126, 194, 195, 152, 153, 154, 206, 207, 208, 155, 156, 157, 209, 210, 211],
    [0, 158, 159, 129, 212, 213],
    [0, 146, 147, 101, 170, 171, 1, 160, 161, 123, 192, 193],
    [0, 146, 147, 108, 214, 215, 1, 160, 161, 127, 196, 197],
    [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191],
    [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195],
    [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191, 152, 153, 154, 182, 183, 184, 162, 163, 164, 198, 199, 200, 155, 156, 157, 185, 186, 187, 165, 166, 167, 201, 202, 203],
    [0, 158, 159, 101, 188, 189, 1, 168, 169, 123, 204, 205],
    [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195, 152, 153, 154, 218, 219, 220, 162, 163, 164, 206, 207, 208, 155, 156, 157, 221, 222, 223, 165, 166, 167, 209, 210, 211],
    [0, 158, 159, 117, 224, 225, 1, 168, 169, 129, 212, 213],
    [0, 146, 147, 16, 226, 227],
    [0, 148, 149, 18, 228, 229],
    [0, 150, 151, 18, 230, 231],
    [0, 150, 151, 16, 232, 233],
    [0, 148, 149, 16, 234, 235],
    [0, 146, 147, 18, 236, 237],
    [0, 146, 147, 52, 238, 239],
    [0, 146, 147, 16, 226, 227, 1, 160, 161, 52, 238, 239],
    [0, 146, 147, 18, 236, 237, 1, 160, 161, 61, 240, 241],
    [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171],
    [0, 148, 149, 18, 228, 229, 242, 172, 181, 243, 214, 244],
    [0, 150, 151, 18, 230, 231, 245, 172, 177, 246, 214, 247],
    [0, 150, 151, 16, 232, 233, 245, 172, 177, 174, 170, 248],
    [0, 148, 149, 16, 234, 235, 242, 172, 181, 178, 170, 249],
    [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215],
    [0, 146, 147, 16, 226, 227, 122, 190, 191, 123, 192, 193],
    [0, 146, 147, 16, 226, 227, 126, 194, 195, 127, 196, 197],
    [0, 146, 147, 18, 236, 237, 126, 194, 195, 123, 192, 193],
    [0, 146, 147, 18, 236, 237, 122, 190, 191, 127, 196, 197],
    [0, 146, 147, 52, 238, 239, 122, 190, 191, 101, 170, 171],
    [0, 146, 147, 61, 240, 241, 126, 194, 195, 101, 170, 171],
    [0, 146, 147, 52, 238, 239, 100, 172, 173, 123, 192, 193],
    [0, 146, 147, 61, 240, 241, 100, 172, 173, 127, 196, 197],
    [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171, 1, 160, 161, 52, 239, 238, 122, 190, 191, 123, 192, 193],
    [0, 146, 147, 16, 226, 227, 109, 216, 217, 108, 214, 215, 1, 160, 161, 52, 239, 238, 126, 194, 195, 127, 196, 197],
    [0, 146, 147, 18, 236, 237, 109, 216, 217, 101, 170, 171, 1, 160, 161, 61, 241, 240, 126, 194, 195, 123, 192, 193],
    [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215, 1, 160, 161, 61, 241, 240, 122, 190, 191, 127, 196, 197],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 66, 67, 44, 45, 332, 333, 334, 335, 336, 337, 338, 339, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 68, 69, 46, 47, 340, 341, 342, 343, 344, 345, 346, 347, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 70, 71, 48, 49, 348, 349, 350, 351, 352, 353, 354, 355, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 72, 73, 50, 51, 356, 357, 358, 359, 360, 361, 362, 363],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413],
    [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 125, 124, 140, 141, 504, 505, 506, 507, 508, 509, 510, 511],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 127, 126, 92, 93, 542, 543, 544, 545, 546, 547, 548, 549],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 481, 480, 483, 482, 486, 487, 484, 485, 491, 490, 489, 488, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 493, 492, 495, 494, 498, 499, 496, 497, 503, 502, 501, 500, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 124, 125, 141, 140, 506, 507, 504, 505, 511, 510, 509, 508],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 519, 518, 521, 520, 524, 525, 522, 523, 529, 528, 527, 526, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 531, 530, 533, 532, 536, 537, 534, 535, 541, 540, 539, 538, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 109, 108, 79, 78, 598, 599, 600, 601, 602, 603, 604, 605, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 126, 127, 93, 92, 544, 545, 542, 543, 549, 548, 547, 546],
    [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 66, 69, 50, 49, 332, 349, 342, 359, 336, 361, 354, 347, 493, 123, 483, 140, 498, 507, 204, 485, 503, 490, 509, 205, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 68, 67, 48, 51, 340, 357, 334, 351, 344, 353, 362, 339, 124, 480, 89, 494, 506, 499, 484, 474, 511, 478, 501, 488, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 70, 73, 46, 45, 348, 333, 358, 343, 352, 345, 338, 363, 122, 492, 141, 482, 475, 487, 496, 505, 479, 510, 489, 500, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 72, 71, 44, 47, 356, 341, 350, 335, 360, 337, 346, 355, 481, 125, 495, 88, 486, 476, 504, 497, 491, 502, 477, 508],
    [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 531, 129, 521, 92, 536, 545, 212, 523, 541, 528, 547, 213, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 126, 518, 91, 532, 544, 537, 522, 512, 549, 516, 539, 526, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 128, 530, 93, 520, 513, 525, 534, 543, 517, 548, 527, 538, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 519, 127, 533, 90, 524, 514, 542, 535, 529, 540, 515, 546],
    [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213],
    [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 551, 550, 553, 552, 556, 557, 554, 555, 561, 560, 559, 558, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369, 563, 562, 565, 564, 568, 569, 566, 567, 573, 572, 571, 570],
    [0, 16],
    [0, 18],
    [0, 16, 26, 20],
    [0, 2, 23, 13],
    [0, 3, 4, 32],
    [0, 2, 29, 15],
    [0, 3, 29, 27],
    [0, 52],
    [0, 63],
    [0, 52, 26, 59],
    [0, 63, 26, 54],
    [0, 52, 16, 1],
    [0, 18, 1, 61],
    [0, 52, 16, 1, 26, 59, 20, 65],
    [0, 31, 1, 63],
    [0, 1, 24, 62],
    [0, 15, 1, 9], // 'P 1 21/n 1'
    // X,Y,Z
    // -X+1/2,Y+1/2,-Z+1/2
    // -X,-Y,-Z
    // X+1/2,-Y+1/2,Z+1/2
    [0, 5, 1, 8], // 'P 1 21/a 1'
    // X,Y,Z
    // -X+1/2,Y+1/2,-Z
    // -X,-Y,-Z
    // X+1/2,-Y+1/2,Z
    [0, 31, 1, 63, 26, 21, 65, 54],
    [0, 2, 57, 56],
    [0, 60, 3, 16],
    [0, 22, 57, 3],
    [0, 2, 28, 20],
    [0, 17, 13, 24],
    [0, 20, 19, 13, 4, 24, 17, 27],
    [0, 22, 57, 3, 4, 16, 60, 32],
    [0, 22, 57, 3, 23, 20, 30, 12, 26, 24, 33, 15, 4, 16, 60, 32],
    [0, 22, 57, 3, 29, 18, 27, 25],
    [0, 22, 3, 57, 1, 55, 10, 37],
    [0, 22, 385, 396, 3, 57, 109, 117],
    [0, 22, 57, 3, 159, 279, 654, 655, 158, 274, 656, 657, 29, 18, 25, 27, 284, 658, 262, 269, 280, 659, 257, 267],
];

export const SpacegroupNameToIndexMap = {
    'P 1': 0,
    'P -1': 1,
    'P 1 2 1': 2,
    'P 1 21 1': 3,
    'C 1 2 1': 4,
    'P 1 m 1': 5,
    'P 1 c 1': 6,
    'C 1 m 1': 7,
    'C 1 c 1': 8,
    'P 1 2/m 1': 9,
    'P 1 21/m 1': 10,
    'C 1 2/m 1': 11,
    'P 1 2/c 1': 12,
    'P 1 21/c 1': 13,
    'C 1 2/c 1': 14,
    'P 2 2 2': 15,
    'P 2 2 21': 16,
    'P 21 21 2': 17,
    'P 21 21 21': 18,
    'C 2 2 21': 19,
    'C 2 2 2': 20,
    'F 2 2 2': 21,
    'I 2 2 2': 22,
    'I 21 21 21': 23,
    'P m m 2': 24,
    'P m c 21': 25,
    'P c c 2': 26,
    'P m a 2': 27,
    'P c a 21': 28,
    'P n c 2': 29,
    'P m n 21': 30,
    'P b a 2': 31,
    'P n a 21': 32,
    'P n n 2': 33,
    'C m m 2': 34,
    'C m c 21': 35,
    'C c c 2': 36,
    'A m m 2': 37,
    'A b m 2': 38,
    'A m a 2': 39,
    'A b a 2': 40,
    'F m m 2': 41,
    'F d d 2': 42,
    'I m m 2': 43,
    'I b a 2': 44,
    'I m a 2': 45,
    'P 2/m 2/m 2/m': 46,
    'P m m m': 46,
    'P 2/n 2/n 2/n': 47,
    'P n n n': 47,
    'P 2/c 2/c 2/m': 48,
    'P c c m': 48,
    'P 2/b 2/a 2/n': 49,
    'P b a n': 49,
    'P 21/m 2/m 2/a': 50,
    'P m m a': 50,
    'P 2/n 21/n 2/a': 51,
    'P n n a': 51,
    'P 2/m 2/n 21/a': 52,
    'P m n a': 52,
    'P 21/c 2/c 2/a': 53,
    'P c c a': 53,
    'P 21/b 21/a 2/m': 54,
    'P b a m': 54,
    'P 21/c 21/c 2/n': 55,
    'P c c n': 55,
    'P 2/b 21/c 21/m': 56,
    'P b c m': 56,
    'P 21/n 21/n 2/m': 57,
    'P n n m': 57,
    'P 21/m 21/m 2/n': 58,
    'P m m n': 58,
    'P 21/b 2/c 21/n': 59,
    'P b c n': 59,
    'P 21/b 21/c 21/a': 60,
    'P b c a': 60,
    'P 21/n 21/m 21/a': 61,
    'P n m a': 61,
    'C 2/m 2/c 21/m': 62,
    'C m c m': 62,
    'C 2/m 2/c 21/a': 63,
    'C m c a': 63,
    'C 2/m 2/m 2/m': 64,
    'C m m m': 64,
    'C 2/c 2/c 2/m': 65,
    'C c c m': 65,
    'C 2/m 2/m 2/a': 66,
    'C m m a': 66,
    'C 2/c 2/c 2/a': 67,
    'C c c a': 67,
    'F 2/m 2/m 2/m': 68,
    'F m m m': 68,
    'F 2/d 2/d 2/d': 69,
    'F d d d': 69,
    'I 2/m 2/m 2/m': 70,
    'I m m m': 70,
    'I 2/b 2/a 2/m': 71,
    'I b a m': 71,
    'I 21/b 21/c 21/a': 72,
    'I b c a': 72,
    'I 21/m 21/m 21/a': 73,
    'I m m a': 73,
    'P 4': 74,
    'P 41': 75,
    'P 42': 76,
    'P 43': 77,
    'I 4': 78,
    'I 41': 79,
    'P -4': 80,
    'I -4': 81,
    'P 4/m': 82,
    'P 42/m': 83,
    'P 4/n': 84,
    'P 42/n': 85,
    'I 4/m': 86,
    'I 41/a': 87,
    'P 4 2 2': 88,
    'P 4 21 2': 89,
    'P 41 2 2': 90,
    'P 41 21 2': 91,
    'P 42 2 2': 92,
    'P 42 21 2': 93,
    'P 43 2 2': 94,
    'P 43 21 2': 95,
    'I 4 2 2': 96,
    'I 41 2 2': 97,
    'P 4 m m': 98,
    'P 4 b m': 99,
    'P 42 c m': 100,
    'P 42 n m': 101,
    'P 4 c c': 102,
    'P 4 n c': 103,
    'P 42 m c': 104,
    'P 42 b c': 105,
    'I 4 m m': 106,
    'I 4 c m': 107,
    'I 41 m d': 108,
    'I 41 c d': 109,
    'P -4 2 m': 110,
    'P -4 2 c': 111,
    'P -4 21 m': 112,
    'P -4 21 c': 113,
    'P -4 m 2': 114,
    'P -4 c 2': 115,
    'P -4 b 2': 116,
    'P -4 n 2': 117,
    'I -4 m 2': 118,
    'I -4 c 2': 119,
    'I -4 2 m': 120,
    'I -4 2 d': 121,
    'P 4/m 2/m 2/m': 122,
    'P4/m m m': 122,
    'P 4/m 2/c 2/c': 123,
    'P4/m c c': 123,
    'P 4/n 2/b 2/m': 124,
    'P4/n b m': 124,
    'P 4/n 2/n 2/c': 125,
    'P4/n n c': 125,
    'P 4/m 21/b 2/m': 126,
    'P4/m b m': 126,
    'P 4/m 21/n 2/c': 127,
    'P4/m n c': 127,
    'P 4/n 21/m 2/m': 128,
    'P4/n m m': 128,
    'P 4/n 2/c 2/c': 129,
    'P4/n c c': 129,
    'P 42/m 2/m 2/c': 130,
    'P42/m m c': 130,
    'P 42/m 2/c 2/m': 131,
    'P42/m c m': 131,
    'P 42/n 2/b 2/c': 132,
    'P42/n b c': 132,
    'P 42/n 2/n 2/m': 133,
    'P42/n n m': 133,
    'P 42/m 21/b 2/c': 134,
    'P42/m b c': 134,
    'P 42/m 21/n 2/m': 135,
    'P42/m n m': 135,
    'P 42/n 21/m 2/c': 136,
    'P42/n m c': 136,
    'P 42/n 21/c 2/m': 137,
    'P42/n c m': 137,
    'I 4/m 2/m 2/m': 138,
    'I4/m m m': 138,
    'I 4/m 2/c 2/m': 139,
    'I4/m c m': 139,
    'I 41/a 2/m 2/d': 140,
    'I41/a m d': 140,
    'I 41/a 2/c 2/d': 141,
    'I41/a c d': 141,
    'P 3': 142,
    'P 31': 143,
    'P 32': 144,
    'H 3': 145,
    'R 3': 146,
    'P -3': 147,
    'H -3': 148,
    'R -3': 149,
    'P 3 1 2': 150,
    'P 3 2 1': 151,
    'P 31 1 2': 152,
    'P 31 2 1': 153,
    'P 32 1 2': 154,
    'P 32 2 1': 155,
    'H 3 2': 156,
    'R 3 2': 157,
    'P 3 m 1': 158,
    'P 3 1 m': 159,
    'P 3 c 1': 160,
    'P 3 1 c': 161,
    'H 3 m': 162,
    'R 3 m': 163,
    'H 3 c': 164,
    'R 3 c': 165,
    'P -3 1 2/m': 166,
    'P -3 1 m': 166,
    'P -3 1 2/c': 167,
    'P -3 1 c': 167,
    'P -3 2/m 1': 168,
    'P -3 m 1': 168,
    'P -3 2/c 1': 169,
    'P -3 c 1': 169,
    'H -3 2/m': 170,
    'H -3 m': 170,
    'R -3 2/m': 171,
    'R -3 m': 171,
    'H -3 2/c': 172,
    'H -3 c': 172,
    'R -3 2/c': 173,
    'R -3 c': 173,
    'P 6': 174,
    'P 61': 175,
    'P 65': 176,
    'P 62': 177,
    'P 64': 178,
    'P 63': 179,
    'P -6': 180,
    'P 6/m': 181,
    'P 63/m': 182,
    'P 6 2 2': 183,
    'P 61 2 2': 184,
    'P 65 2 2': 185,
    'P 62 2 2': 186,
    'P 64 2 2': 187,
    'P 63 2 2': 188,
    'P 6 m m': 189,
    'P 6 c c': 190,
    'P 63 c m': 191,
    'P 63 m c': 192,
    'P -6 m 2': 193,
    'P -6 c 2': 194,
    'P -6 2 m': 195,
    'P -6 2 c': 196,
    'P 6/m 2/m 2/m': 197,
    'P 6/m m m': 197,
    'P 6/m 2/c 2/c': 198,
    'P 6/m c c': 198,
    'P 63/m 2/c 2/m': 199,
    'P 63/m c m': 199,
    'P 63/m 2/m 2/c': 200,
    'P 63/m m c': 200,
    'P 2 3': 201,
    'F 2 3': 202,
    'I 2 3': 203,
    'P 21 3': 204,
    'I 21 3': 205,
    'P 2/m -3': 206,
    'P m -3': 206,
    'P 2/n -3': 207,
    'P n -3': 207,
    'F 2/m -3': 208,
    'F m -3': 208,
    'F 2/d -3': 209,
    'F d -3': 209,
    'I 2/m -3': 210,
    'I m -3': 210,
    'P 21/a -3': 211,
    'P a -3': 211,
    'I 21/a -3': 212,
    'I a -3': 212,
    'P 4 3 2': 213,
    'P 42 3 2': 214,
    'F 4 3 2': 215,
    'F 41 3 2': 216,
    'I 4 3 2': 217,
    'P 43 3 2': 218,
    'P 41 3 2': 219,
    'I 41 3 2': 220,
    'P -4 3 m': 221,
    'F -4 3 m': 222,
    'I -4 3 m': 223,
    'P -4 3 n': 224,
    'F -4 3 c': 225,
    'I -4 3 d': 226,
    'P 4/m -3 2/m': 227,
    'P m -3 m': 227,
    'P 4/n -3 2/n': 228,
    'P n -3 n': 228,
    'P 42/m -3 2/n': 229,
    'P m -3 n': 229,
    'P 42/n -3 2/m': 230,
    'P n -3 m': 230,
    'F 4/m -3 2/m': 231,
    'F m -3 m': 231,
    'F 4/m -3 2/c': 232,
    'F m -3 c': 232,
    'F 41/d -3 2/m': 233,
    'F d -3 m': 233,
    'F 41/d -3 2/c': 234,
    'F d -3 c': 234,
    'I 4/m -3 2/m': 235,
    'I m -3 m': 235,
    'I 41/a -3 2/d': 236,
    'I a -3 d': 236,
    'P 1 1 2': 237,
    'P 1 1 21': 238,
    'B 1 1 2': 239,
    'B 2': 239,
    'A 1 2 1': 240,
    'C 1 21 1': 241,
    'I 1 2 1': 242,
    'I 2': 242,
    'I 1 21 1': 243,
    'P 1 1 m': 244,
    'P 1 1 b': 245,
    'B 1 1 m': 246,
    'B 1 1 b': 247,
    'P 1 1 2/m': 248,
    'P 1 1 21/m': 249,
    'B 1 1 2/m': 250,
    'P 1 1 2/b': 251,
    'P 1 1 21/b': 252,
    'P 1 21/n 1': 253,
    'P 1 21/a 1': 254,
    'B 1 1 2/b': 255,
    'P 21 2 2': 256,
    'P 2 21 2': 257,
    'P 21 21 2 (a)': 258,
    'P 21 2 21': 259,
    'P 2 21 21': 260,
    'C 2 2 21a)': 261,
    'C 2 2 2a': 262,
    'F 2 2 2a': 263,
    'I 2 2 2a': 264,
    'P 21/m 21/m 2/n a': 265,
    'P 42 21 2a': 266,
    'I 2 3a': 267,
};

export function getSpacegroupIndexFromNumber(num: number) {
    // 38 spacegroup variants as given CCP4s symop.lib
    switch (num) {
        case 1146: return 146;
        case 1148: return 149;
        case 1155: return 157;
        case 1160: return 163;
        case 1161: return 165;
        case 1166: return 171;
        case 1167: return 173;

        case 1003: return 237; // 'P 1 1 2'  !(dyad along z)
        case 1004: return 238; // 'P 1 1 21'  !(unique axis c)
        case 1005: return 239; // 'B 1 1 2' 'B 2'
        case 2005: return 240; // 'A 1 2 1'
        case 3005: return 241; // 'C 1 21 1' ! (Origin on screw at 1/4X)
        case 4005: return 242; // 'I 1 2 1' 'I 2' !!! GJK @ 2003-06-02
        case 5005: return 243; // 'I 1 21 1'
        case 1006: return 244; // 'P 1 1 m'
        case 1007: return 245; // 'P 1 1 b'
        case 1008: return 246; // 'B 1 1 m'
        case 1009: return 247; // 'B 1 1 b'
        case 1010: return 248; // 'P 1 1 2/m'
        case 1011: return 249; // 'P 1 1 21/m'
        case 1012: return 250; // 'B 1 1 2/m'
        case 1013: return 251; // 'P 1 1 2/b'
        case 1014: return 252; // 'P 1 1 21/b'
        case 2014: return 253; // 'P 1 21/n 1'
        case 3014: return 254; // 'P 1 21/a 1'
        case 1015: return 255; // 'B 1 1 2/b'
        case 1017: return 256; // 'P 21 2 2' !(unique axis a)
        case 2017: return 257; // 'P 2 21 2' !(unique axis b)
        case 1018: return 258; // 'P 21 21 2 (a)' ! origin on 21 21, shift (1/4,1/4,0)
        case 2018: return 259; // 'P 21 2 21'  !(unique axis b)
        case 3018: return 260; // 'P 2 21 21'  !(unique axis a)
        case 1020: return 261; // 'C 2 2 21a)' ! P212121 with C centring, shift(1/4,0,0)
        case 1021: return 262; // 'C 2 2 2a'  ! C21212a origin on 21 21
        case 1022: return 263; // 'F 2 2 2a' ! same as 1018 with face centring  shift (1/4,0,0)
        case 1023: return 264; // 'I 2 2 2a'  ! as 1018 with origin shift (1/4,1/4,1/4)
        case 1059: return 265; // 'P 21/m 21/m 2/n a'
        case 1094: return 266; // 'P 42 21 2a' ! (as P21212a) origin on 21 21 ie Shift 1/4,1/4,1/4
        case 1197: return 267; // 'I 2 3a' ! Expansion of 1023 which is an expansion of 1018
    }

    let offset = 0;
    if (num > 146) ++offset;
    if (num > 148) ++offset;
    if (num > 155) ++offset;
    if (num > 160) ++offset;
    if (num > 161) ++offset;
    if (num > 166) ++offset;
    if (num > 167) ++offset;

    return num - 1 + offset;
}

export function getSpacegroupNumberFromIndex(idx: number) {
    if (idx < 146) return idx + 1;
    if (idx === 146) return 1146;

    if (idx < 149) return idx + 1 - 1;
    if (idx === 149) return 1148;

    if (idx < 157) return idx + 1 - 2;
    if (idx === 157) return 1155;

    if (idx < 163) return idx + 1 - 3;
    if (idx === 163) return 1160;

    if (idx < 165) return idx + 1 - 4;
    if (idx === 165) return 1161;

    if (idx < 171) return idx + 1 - 5;
    if (idx === 171) return 1166;

    if (idx < 173) return idx + 1 - 6;
    if (idx === 173) return 1167;

    if (idx < 237) return idx + 1 - 7;
    if (idx === 237) return 1003;
    if (idx === 238) return 1004;
    if (idx === 239) return 1005;
    if (idx === 240) return 2005;
    if (idx === 241) return 3005;
    if (idx === 242) return 4005;
    if (idx === 243) return 5005;
    if (idx === 244) return 1006;
    if (idx === 245) return 1007;
    if (idx === 246) return 1008;
    if (idx === 247) return 1009;
    if (idx === 248) return 1010;
    if (idx === 249) return 1011;
    if (idx === 250) return 1012;
    if (idx === 251) return 1013;
    if (idx === 252) return 1014;

    if (idx === 253) return 2014;
    if (idx === 254) return 3014;
    if (idx === 255) return 1015;
    if (idx === 256) return 1017;
    if (idx === 257) return 2017;
    if (idx === 258) return 1018;
    if (idx === 259) return 2018;
    if (idx === 260) return 3018;
    if (idx === 261) return 1020;
    if (idx === 262) return 1021;
    if (idx === 263) return 1022;
    if (idx === 264) return 1023;
    if (idx === 265) return 1059;
    if (idx === 266) return 1094;
    if (idx === 267) return 1197;

    throw new Error(`unknown spacegroup index '${idx}'`);
}

export type SpacegroupName = keyof typeof SpacegroupNameToIndexMap

/** Maps spacegroup index to Hermann-Mauguin spacegroup name */
export const SpacegroupName: { [idx: number]: SpacegroupName } = (function () {
    const names = Object.create(null);
    for (const n of Object.keys(SpacegroupNameToIndexMap)) {
        names[(SpacegroupNameToIndexMap as any)[n]] = n;
    }
    return names;
}());

/** Maps spacegroup index to spacegroup number from International Tables for Crystallography */
export const SpacegroupNumber: { [idx: number]: number } = (function () {
    const numbers = Object.create(null);
    for (const n of Object.keys(SpacegroupNameToIndexMap)) {
        const idx = (SpacegroupNameToIndexMap as any)[n];
        numbers[idx] = getSpacegroupNumberFromIndex(idx);
    }
    return numbers;
}());

/** return -1 if the spacegroup does not exist */
export function getSpacegroupIndex(nameOrNumber: number | string | SpacegroupName): number {
    const index = typeof nameOrNumber === 'number'
        ? getSpacegroupIndexFromNumber(nameOrNumber)
        : SpacegroupNameToIndexMap[nameOrNumber as SpacegroupName];
    if (typeof index === 'undefined' || typeof SpacegroupName[index] === 'undefined') return -1;
    return index;
}